package com.joysuch.wwyt.licence.constant;

/**
 *
 *
 * @author jialei
 * @date 2022-04-28
 */
public enum LicenceStateEnum {
    /**
     * 系统中授权 licence 状态
     */
    INIT(900, "Licence需要初始化"), OVERDUE(901, "Licence授权过期"), FUTURE(902, "Licence授权未到期"),
    /**
     * licence 文件解析状态
     */
    FILE_DOES_NOT_EXIST(910, "文件不存在"), ILLEGAL_FILE(911, "上传文件不合法"), FILE_TOO_LARGE(912, "上传文件大小超过"),
    FILE_EXIST(913, "Licence已存在"),
    /**
     * licence 内容校验状态
     */
    LICENCE_ERROR(920, "文件错误，请检查后重新上传"), LICENCE_ERROR_TYPE(921, "不是该平台的Licence,请检查后重新上传"), LICENCE_PERMISSION_EMPTY(922, "授权模块为空，请检查后重新上传"),
    LICENCE_ERROR_BUILD_ID(923, "不属于当前项目Licence,请检查后重新上传"),
    /**
     * 非法操作
     */
    LICENCE_NOT_FOUND_BUILD_ID(998, "项目信息不存在"), LICENCE_ERROR_BASE_MODULE_MENU(999, "模块菜单表信息被篡改");
    private int value;
    private String desc;

    LicenceStateEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 根据value查找对应描述
     * @param value
     * @return
     */
    public static String value2Desc(int value) {
        LicenceStateEnum[] LICENCEStateEnums = LicenceStateEnum.values();
        for (LicenceStateEnum LICENCEStateEnum : LICENCEStateEnums) {
            if (LICENCEStateEnum.getValue() == value) {
                return LICENCEStateEnum.getDesc();
            }
        }
        return "未知状态";
    }
}